import mhttp from './common/http.js'

Vue.prototype.$api = {
	get:mhttp.myGet,
	post:mhttp.myPost,
	uploadfile:mhttp.uploadfile,
    postURL:mhttp.postURL,
    loginout:mhttp.loginout,
    imgURL:mhttp.imgURL
};
Vue.prototype.$in_array = function(item,array){
    var verdict = false;
    for(var i=0;i<array.length;i++){
      if(array[i]===item){
        verdict = i;
        break;
      }
    }
    return verdict;
}
Vue.config.productionTip = false

Vue.prototype.$islogin = ()=>{
	let token = uni.getStorageSync('baiyanjing_login_token');
	return token?true:false;
}
Vue.prototype.$backnav = ()=>{
    uni.navigateBack()
}
Vue.prototype.$navto = (path)=>{
    uni.navigateTo({
        url:path
    })
}
Vue.prototype.$error = (msg)=>{
    uni.showToast({
        title:msg,
        icon:"none",
        duration: 2000
    })
}
Vue.prototype.$success = (msg)=>{
    uni.showToast({
        title:msg,
        icon:"success",
        duration: 2000
    })
}
Vue.prototype.$confirm = (msg)=>{
    return new Promise((resolve, reject)=>{
        uni.showModal({
            content:msg,
            success:function(r){
                if (r.confirm) {
                    resolve()
                } 
            }    
        })
    })
}
Vue.prototype.$alert = (msg)=>{
    return new Promise((resolve, reject)=>{
        uni.showModal({
            content:msg,
            showCancel:false,
            success:function(r){
                if (r.confirm) {
                    resolve()
                } 
            }    
        })
    })
}

// #ifndef VUE3
import Vue from 'vue'
import App from './App'

Vue.config.productionTip = false

App.mpType = 'app'

const app = new Vue({
    ...App
})
app.$mount()
// #endif

// #ifdef VUE3
import { createSSRApp } from 'vue'
import App from './App.vue'
export function createApp() {
  const app = createSSRApp(App)
  return {
    app
  }
}
// #endif